package work20241204.b_static;

/**
 * @author zdl
 * @date 2024/12/4
 */
class Animal{
    String name;
    static int count = 0;
    public Animal(){
        System.out.println("这是一个无参构造");
    }
    public void help(){
        System.out.println("help");

    }
    public static void water(){

        count++;
    }
    public static void eat(){
        System.out.println("吃东西");
    }
    {
        System.out.println("这是一个代码块");
    }
    static {
        System.out.println("这是一个静态代码块");
    }
}
public class Demo2 {
    public static void main(String[] args) {
        //Animal.eat();
        Animal animal = new Animal();
        Animal.water();
        System.out.println(Animal.count);
        System.out.println();
        Animal animal1 = new Animal();
        Animal.water();
        System.out.println(Animal.count);

    }
}
